package com.haofengsoft.scce.controller.consultation;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.haofengsoft.scce.adapter.information.StoneGoldModel;

/**
 * Created by admin on 2015/7/14.
 */
public class StoneGoldController {
	private static StoneGoldController instance = null;
	private Context appContext;

	public static synchronized StoneGoldController getInstance(Context context) {
		if (instance == null) {
			instance = new StoneGoldController(context);
		}
		return instance;
	}

	public StoneGoldController(Context appContext) {
		this.appContext = appContext;
	}

	public List<StoneGoldModel> handleStoneGoldModelList(String json) {
		try {
			List<StoneGoldModel> modelList = new ArrayList<StoneGoldModel>();
			JSONArray newsModelArray = JSON.parseObject(json).getJSONArray("NewList");
			for (int i = 0; i < newsModelArray.size(); i++) {
				JSONObject newsModelObj = newsModelArray.getJSONObject(i);
				StoneGoldModel model = new StoneGoldModel();
				model.setId(newsModelObj.getString("ID"));
				model.setTime(newsModelObj.getString("StrCreateDate"));
				model.setDetail(newsModelObj.getString("Summary"));
				model.setTitle(newsModelObj.getString("Title"));
				model.setSoure(newsModelObj.getString("Soure"));
				modelList.add(model);
			}
			if (modelList.size() < 1) {
				modelList = null;
			}
			return modelList;

		} catch (Exception e) {
			return null;
		}
	}
}
